<template>
	<!--自定义底部导航栏-->
	<view class="bottombox">
		<view class="bottombox-item" v-for="(list,index) in tabList" :key="index" @click="handleTab(list,index)">
			<image :src="tabIndex == index?list.iconPath : list.selectIconPath" class="tab-img" />
			<text class="contentfont">{{list.text}}</text>
		</view>
	</view>
</template>

<script setup>
	import {
		ref,
		reactive,
		defineProps,
		toRefs
	} from 'vue'
	const props = defineProps({
		tabIndex: {
			type: Number,
			default: 0
		}
	})
	const {
		tabIndex
	} = toRefs(props)
	let tabList = reactive([{
			pagePath: '/pages/ticketList/index',
			iconPath: '/static/images/ticket.png',
			selectIconPath: '/static/images/selectticket.png',
			text: '工单'
		},
		{
			pagePath: '/pages/mine/index',
			iconPath: '/static/images/mine.png',
			selectIconPath: '/static/images/selectmine.png',
			text: '我的'
		}
	])
	const handleTab = (val, idx) => {
		if (idx == 0) {
			uni.switchTab({
				url: tabList[idx].pagePath
			})
		} else {
			uni.switchTab({
				url: tabList[idx].pagePath
			})
		}

	}
</script>

<style lang="scss">
	.t-icon {
		width: 48rpx;
		height: 48rpx;
	}

	.bottombox {
		position: fixed;
		bottom: 0;
		left: 0;
		display: flex;
		align-items: center;
		align-content: center;
		width: 100%;
		height: 152rpx;
		text-align: center;
		background: #FFFFFF;
		box-shadow: 0 -4rpx 20rpx 0 #296dfa14;

		.bottombox-item {
			flex: 1;
			display: flex;
			flex-direction: column;
			align-items: center;

			.tab-img {
				width: 48rpx;
				height: 48rpx;
			}

			.contentfont {
				margin-bottom: 30rpx;
				font-family: PingFangSC-Regular;
				font-weight: 400;
				font-size: 20rpx;
				color: #535362;
			}
		}
	}
</style>